package analysis;

import static org.junit.Assert.assertTrue;

import java.io.File;

import model.SysClass;
import model.SysMethod;
import model.SysRoot;

import org.junit.Test;


public class ClassAnalysisTest {
  
  String pathToP1 = "."+File.separator+"test-programs"+File.separator+
  	"PackInPack_lotsOfClassesInSinglePack"+File.separator+"bin";
  String pathToP2 = "."+File.separator+"test-programs"+File.separator+
  	"DefaultPackage"+File.separator+"bin";
  String pathToHashKnowledgement = pathToP1 +File.separator+"pack1"+File.separator+
  	"rapidinho"+File.separator+"HashKnowlegment.class";
  
  /*make new .classes to run this test*/
  @Test
  public void sameClasses(){
    SysClass c = new SysClass("HashKnowlegment");
    c.add(new SysMethod(false, "<init>", "void", "public")); //constructor
    SysMethod main =new SysMethod(true, "main", "void", "public");
    main.addParameter("[java/lang/String");
    c.add(main);
    c.setSuperClass(new SysClass("Ljava.lang.Object"));
    
    SysClass c1 = new SysClass("HashKnowlegment");
    int i = pathToHashKnowledgement.lastIndexOf(File.separator);
    SysRoot r = new SysRoot(pathToHashKnowledgement.substring(0,i));
    ClassAnalysis2.analyseClass(c1, r);
    
    boolean equals = true;
    if(!c1.getFields().equals(c.getFields())) equals = false;
    for(SysMethod m : c1.getMethods()){
      if(!c.contains(m)) equals = false;
    }
    assertTrue(equals);
  }
  
  @Test
  public void sameClasses1(){
  	SysClass c1 = new SysClass("A");
  	SysClass c2 = new SysClass("A");
  	assertTrue(c1.equals(c2));
  }

}
